<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
            list-style: none;
        }
        ul{
            display: flex;
        }
        li{
            border: 1px solid #000;
            margin: 10px;
        }
        li img{
            width: 50px;
            height: 50px;
        }
        .left img {
            width: 300px;
            height: 300px;
        }
    </style>
</head>
<body>

    <div class="left">
        <img src="" alt="">
    </div>
    <ul>
       
    </ul>


    <script>

        var smallImgSrc = ['../images/girlsmall1.jpg' , '../images/girlsmall2.jpg' , '../images/girlsmall3.jpg' , '../images/girlsmall4.jpg'] ;

        var bigImgSrc = ['../images/girlbig1.jpg' , '../images/girlbig2.jpg' , '../images/girlbig3.jpg' , '../images/girlbig4.jpg'] ;


        var oUl = document.querySelector('ul') ;
        var oLeftImg = document.querySelector('.left img') ;

        // 默认显示第一张大图
        oLeftImg.src = bigImgSrc[0] ;

        // 渲染小图列表
        var res = '' ;
        for(var i = 0 ; i < smallImgSrc.length ; i++) {
            res += `
                <li>
                    <img src="${smallImgSrc[i]}" alt="" data="${bigImgSrc[i]}">
                </li>
            `
        }
        oUl.innerHTML = res ;


        oUl.addEventListener('mouseover' , function(e) {
            if(e.target.tagName === 'IMG') {
                // console.log(e.target);
                // oLeftImg.src = e.target.src ;
                var src = e.target.getAttribute('data') ;
                oLeftImg.src = src ;
            }
        })

    </script>
    
</body>
</html>